home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / windows / comms / recomm10.arj / WNETBIOS.C < prev    next >
C/C++ Source or Header  |  1993-10-12  |  27KB  |  1,343 lines

  1. #include <windows.h>
  2. #include <dos.h>
  3. #include <memory.h>
  4. #include "wnetbios.h"
  5.  
  6.  
  7. #define WM_NETBIOS_NOTIFY   WM_USER+0x5000
  8.  
  9.  
  10. static void _loadds cdecl interrupt far PostHandler(void);
  11.  
  12. static BOOL PASCAL WaitForResponse(WMODE Mode, HWND hwnd, LPNCB lpNCB);
  13.  
  14. int  FAR PASCAL LibMain(HANDLE hModule, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine);
  15. int  FAR PASCAL WEP (int bSystemExit);
  16.  
  17.  
  18. HANDLE  hLibrary = NULL;
  19. int net_errno;
  20.  
  21.  
  22. BOOL FAR PASCAL LibMain(HANDLE hInstance,
  23. WORD   wDataSeg,
  24. WORD   wHeapSize,
  25. LPSTR  lpCmdLine)
  26. {
  27.     hLibrary = hInstance;
  28.     
  29.     _fmemset(&allNCB, 0, sizeof(allNCB));
  30.     
  31.     return(TRUE);
  32. }                         
  33. // ------------------------- INLINE ASM -----------------------------------
  34.  
  35. #pragma optimize ("", off)
  36.  
  37. #pragma alloc_text(FIXEDSEG, WEP)
  38. int FAR PASCAL WEP(int bSystemExit)
  39. {
  40.     return(TRUE);
  41. }
  42.  
  43. #pragma alloc_text(FIXEDSEG, PostHandler)
  44.  
  45. static void _loadds cdecl interrupt far PostHandler(void)
  46. {
  47.     LPNCB lpNCB;
  48.     
  49.     /* ES:BX => NCB structure */
  50.     _asm {
  51.         mov     word ptr lpNCB,bx
  52.         mov     word ptr lpNCB+2,es
  53.     }
  54.     PostMessage(lpNCB->post.hwndPost, lpNCB->post.wMsgPost,    lpNCB->post.wParam,    (LONG) lpNCB);
  55.     return;
  56. }
  57.  
  58.  
  59. WORD FAR PASCAL _export SendNetBIOS(LPNCB lpNCB)
  60. {
  61.     WORD    wErrCode;
  62.     extern WORD FAR PASCAL NetBIOSCall(void);
  63.     
  64.     lpNCB->fnPost = 0L;
  65.     
  66.     _asm {
  67.         push    ax
  68.         push    bx
  69.         push    es
  70.         les     bx,lpNCB
  71.         call    NetBIOSCall
  72.         xor     ah,ah
  73.         mov     al,byte ptr es:[bx].cRetcode
  74.         mov     wErrCode,ax
  75.         pop     es
  76.         pop     bx
  77.         pop     ax
  78.     }
  79.     net_errno = wErrCode;
  80.     return(wErrCode);
  81. }
  82.  
  83. WORD FAR PASCAL _export PostNetBIOS(LPNCB lpNCB,HWND  hwndPost,WORD  wMsgPost,WORD  wParam)
  84. {
  85.     WORD    wErrCode;
  86.     extern WORD FAR PASCAL NetBIOSCall(void);
  87.     
  88.     
  89.     lpNCB->post.hwndPost = hwndPost;
  90.     lpNCB->post.wMsgPost = wMsgPost;
  91.     lpNCB->post.wParam   = wParam;
  92.     
  93.     lpNCB->cCommand |= NO_WAIT;
  94.     
  95.     
  96.     _asm {
  97.         push    ax
  98.         push    bx
  99.         push    es
  100.         les     bx,lpNCB
  101.         call    NetBIOSCall
  102.         xor     ah,ah
  103.         mov     wErrCode,ax
  104.         pop     es
  105.         pop     bx
  106.         pop     ax
  107.     }
  108.     net_errno = wErrCode;
  109.     return(wErrCode);
  110. }
  111. #pragma optimize ("", on)
  112. // -------------------------- END INLINE ASM -----------------------------------------
  113.  
  114.  
  115. static BOOL PASCAL WaitForResponse(WMODE Mode, HWND hwnd, LPNCB lpNCB)
  116. {
  117.     MSG  msg;
  118.     HWND hwndMsg;
  119.     
  120.     if(Mode == WAIT_APP_MODAL)
  121.     {
  122.          hwndMsg = hwnd; 
  123.     }else
  124.     {
  125.          hwndMsg = NULL;
  126.     }    
  127.     while(lpNCB->cCmdCplt == 0x00ff)
  128.     {
  129.         while (PeekMessage(&msg, hwndMsg, 0, 0, PM_REMOVE))            
  130.         {
  131.             TranslateMessage(&msg);
  132.             DispatchMessage(&msg);
  133.             
  134.             if ( (msg.hwnd == hwnd)
  135.             && (msg.message == WM_NCDESTROY))
  136.             {
  137.                 return FALSE;
  138.             }
  139.             if(lpNCB->cCmdCplt != 0xff)    return TRUE;
  140.         }
  141.     }
  142.     return TRUE; // Call completed
  143. }
  144.  
  145. BOOL FAR PASCAL _export CancelAllPending(HWND hwndPost)
  146. {
  147.     int x;
  148.     
  149.     for(x = 0; x < MAX_NCB; x++)
  150.     {
  151.         if( (allNCB[x].used == 1)
  152.         &&  (allNCB[x].post.hwndPost == hwndPost))
  153.         {
  154.             _fmemset(&privNCB, 0, sizeof(privNCB));
  155.             privNCB.cCommand = NETBIOS_CANCEL;
  156.             privNCB.cAdapterNum = allNCB[x].cAdapterNum;
  157.             privNCB.lpBuffer = (LPSTR)&allNCB[x];       
  158.             
  159.             SendNetBIOS(&privNCB);
  160.             allNCB[x].used = 0;
  161.         }   
  162.     }
  163.     return(TRUE);
  164. }
  165.  
  166. LPNCB FAR PASCAL _export CreateNCB(BYTE cCommand, BYTE cAdapterNum)
  167. {
  168.     int x;
  169.     
  170.     for(x = 0; x < MAX_NCB; x++)
  171.     {
  172.         if(allNCB[x].used == 0)
  173.         {
  174.             _fmemset(&allNCB[x], 0, sizeof(privNCB));
  175.             
  176.             allNCB[x].cCommand = cCommand;
  177.             allNCB[x].cAdapterNum = cAdapterNum;
  178.             allNCB[x].cRetcode = 0xff;
  179.             allNCB[x].fnPost = (FARPROC) (void far *) PostHandler;
  180.             _fmemset(allNCB[x].cName, ' ', MAX_NAME_SIZE);
  181.             _fmemset(allNCB[x].cCallName, ' ', MAX_NAME_SIZE);
  182.             allNCB[x].used = 1;
  183.             
  184.             return(&allNCB[x]);
  185.         }   
  186.     }                
  187.     net_errno = NB_NO_FREE_NCB_ERR;
  188.     return(NULL);
  189. }
  190.  
  191. BOOL FAR PASCAL _export DestroyNCB(LPNCB lpNCB)
  192. {
  193.     if(lpNCB->cCmdCplt == 0xff)
  194.     {
  195.         // OutputDebugString("err WNETBIOS: tried to destroy pending Call\n");
  196.         return FALSE;
  197.     }
  198.     _fmemset(lpNCB, 0, sizeof(NCB));
  199.     
  200.     return(TRUE);
  201. }       
  202.  
  203. WORD FAR PASCAL _export SubmitNCB(WMODE Mode, LPNCB lpNCB, HWND hwndPost)
  204. {
  205.     
  206.     WORD     wErrCode;
  207.     
  208.     // wenn FensterHandle ungⁿltig dann blockierter Call
  209.     
  210.     if (!IsWindow(hwndPost) || Mode == WAIT_SYS_MODAL)
  211.     {
  212.         wErrCode = SendNetBIOS(lpNCB);
  213.     }
  214.     else
  215.     {
  216.         lpNCB->cCommand |= NO_WAIT;
  217.         wErrCode = SendNetBIOS(lpNCB);
  218.         
  219.         if( (wErrCode == 0x00ff)
  220.         ||  (wErrCode == 0x0000))
  221.         {                 
  222.             if(lpNCB->cCmdCplt == 0x00ff)
  223.             {
  224.                 if (WaitForResponse(Mode, hwndPost, lpNCB) == FALSE)
  225.                 {    
  226.                     // OutputDebugString("err WNETBIOS: Response Window destroyed\n");
  227.                     Cancel(lpNCB->cAdapterNum, lpNCB);
  228.                     net_errno = wErrCode = NB_WAIT_FOR_RESPONSE_ERR;
  229.                 }else
  230.                 {
  231.                     net_errno = wErrCode = lpNCB->cCmdCplt;
  232.                 }
  233.             }else
  234.             {
  235.                 net_errno = wErrCode = lpNCB->cCmdCplt;
  236.             }
  237.         }
  238.     }
  239.     return(wErrCode);
  240. }
  241.  
  242. BOOL FAR PASCAL _export IsNetBIOSLoaded(void)
  243. {
  244.     LPNCB  lpNCB;
  245.     WORD   wErrCode;
  246.     
  247.     if (!_dos_getvect(0x5c))
  248.     return (FALSE);
  249.     
  250.     lpNCB = CreateNCB(NETBIOS_INVALID_COMMAND, 0);
  251.     
  252.     if (lpNCB == NULL)
  253.     {
  254.         return(NB_NO_FREE_NCB_ERR);
  255.     }
  256.     wErrCode = SendNetBIOS(lpNCB);
  257.     
  258.     DestroyNCB(lpNCB);
  259.     
  260.     if (wErrCode != NB_INVALID_COMMAND)
  261.     {
  262.         return (FALSE);
  263.     }
  264.     return(TRUE);
  265. }
  266.  
  267.  
  268.  
  269. WORD FAR PASCAL _export AddName(WMODE  Mode,LPSTR  szName,BYTE   cAdapterNum, 
  270.     HWND   hwndPost,LPBYTE cNum)        
  271. {
  272.     LPNCB  lpNCB;
  273.     WORD   wErrCode;
  274.     
  275.     lpNCB = CreateNCB(NETBIOS_ADD_NAME, cAdapterNum);
  276.  
  277.     if (lpNCB == NULL)
  278.     {
  279.         return(NB_NO_FREE_NCB_ERR);
  280.     }
  281.     if (lstrlen(szName) > MAX_NAME_SIZE)
  282.     {
  283.         szName[MAX_NAME_SIZE] = '\0';
  284.     }
  285.     _fmemcpy(lpNCB->cName, szName, lstrlen(szName));
  286.     
  287.     wErrCode = SubmitNCB(Mode, lpNCB, hwndPost);
  288.     
  289.     if (wErrCode == 0)
  290.     {
  291.         *cNum = lpNCB->cNum;
  292.     }
  293.     DestroyNCB(lpNCB);
  294.     return(wErrCode);
  295. }
  296.  
  297.  
  298. WORD FAR PASCAL _export PostAddName(LPSTR szName, BYTE  cAdapterNum, HWND  hwndPost,     
  299.     WORD  wMsgPost, WORD  wParam, LPNCB FAR *lpRetNCB) 
  300. {
  301.     LPNCB  lpNCB;
  302.     WORD   wErrCode;
  303.     
  304.     if (!IsWindow(hwndPost))
  305.     {
  306.         return(NB_INVALID_WINDOW);
  307.     }
  308.     
  309.     lpNCB = CreateNCB(NETBIOS_ADD_NAME, cAdapterNum);
  310.     
  311.     if (lpNCB == NULL)
  312.     {
  313.         return(NB_NO_FREE_NCB_ERR);
  314.     }
  315.     if (lstrlen(szName) > MAX_NAME_SIZE)
  316.     {
  317.         szName[MAX_NAME_SIZE] = '\0';
  318.     }                     
  319.     
  320.     _fmemcpy(lpNCB->cName, szName, lstrlen(szName));
  321.     
  322.     wErrCode = PostNetBIOS(lpNCB,hwndPost,wMsgPost,wParam);
  323.     
  324.     if (wErrCode != 0)
  325.     {
  326.         DestroyNCB(lpNCB);
  327.     }
  328.     else
  329.     {
  330.         *lpRetNCB = lpNCB;
  331.     }
  332.     return(wErrCode);
  333. }
  334.  
  335.  
  336. WORD FAR PASCAL _export AddGroupName(WMODE  Mode, LPSTR szName, BYTE  cAdapterNum,  
  337.     HWND  hwndPost, LPBYTE cNum)        
  338. {
  339.     LPNCB  lpNCB;
  340.     WORD   wErrCode;
  341.     
  342.     lpNCB = CreateNCB(NETBIOS_ADD_GROUP_NAME, cAdapterNum);
  343.     
  344.     if (lpNCB == NULL)
  345.     {
  346.         return(NB_NO_FREE_NCB_ERR);
  347.     }
  348.     
  349.     if (lstrlen(szName) > MAX_NAME_SIZE)
  350.     {
  351.         szName[MAX_NAME_SIZE] = '\0';
  352.     }
  353.     _fmemcpy(lpNCB->cName, szName, lstrlen(szName));
  354.     
  355.     wErrCode = SubmitNCB(Mode, lpNCB, hwndPost);
  356.     
  357.     if (wErrCode == 0)
  358.     {
  359.         *cNum = lpNCB->cNum;
  360.     }
  361.     DestroyNCB(lpNCB);
  362.     
  363.     return(wErrCode);
  364. }
  365.  
  366.  
  367. WORD FAR PASCAL _export PostAddGroupName(LPSTR szName, BYTE  cAdapterNum, HWND  hwndPost,     
  368.     WORD  wMsgPost, WORD  wParam, LPNCB FAR *lpRetNCB) 
  369. {
  370.     LPNCB  lpNCB;
  371.     WORD   wErrCode;
  372.     
  373.     if (!IsWindow(hwndPost))
  374.     {
  375.         return(NB_INVALID_WINDOW);
  376.     }
  377.     
  378.     lpNCB = CreateNCB(NETBIOS_ADD_GROUP_NAME, cAdapterNum);
  379.     
  380.     if (lpNCB == NULL)
  381.     {
  382.         return(NB_NO_FREE_NCB_ERR);
  383.     }
  384.     
  385.     if (lstrlen(szName) > MAX_NAME_SIZE)
  386.     {
  387.         szName[MAX_NAME_SIZE] = '\0';
  388.     }
  389.     
  390.     _fmemcpy(lpNCB->cName, szName, lstrlen(szName));
  391.     
  392.     wErrCode = PostNetBIOS(lpNCB,hwndPost,wMsgPost,wParam);
  393.     
  394.     if (wErrCode != 0)
  395.     {
  396.         DestroyNCB(lpNCB);
  397.     }
  398.     else
  399.     {
  400.         *lpRetNCB = lpNCB;
  401.     }
  402.     return(wErrCode);
  403. }
  404.  
  405.  
  406. WORD FAR PASCAL _export DeleteName(WMODE  Mode, LPSTR  szName, BYTE   cAdapterNum, 
  407.     HWND   hwndPost)    
  408. {
  409.     LPNCB  lpNCB;
  410.     WORD   wErrCode;
  411.     
  412.     lpNCB = CreateNCB(NETBIOS_DELETE_NAME, cAdapterNum);
  413.  
  414.     if (lpNCB == NULL)
  415.     {
  416.         return(NB_NO_FREE_NCB_ERR);
  417.     }
  418.     
  419.     if (lstrlen(szName) > MAX_NAME_SIZE)
  420.     {
  421.         szName[MAX_NAME_SIZE] = '\0';
  422.     }
  423.     
  424.     _fmemcpy(lpNCB->cName, szName, lstrlen(szName));
  425.     
  426.     wErrCode = SubmitNCB(Mode, lpNCB, hwndPost);
  427.     
  428.     DestroyNCB(lpNCB);
  429.     return(wErrCode);
  430. }
  431.  
  432.  
  433. WORD FAR PASCAL _export PostDeleteName(LPSTR szName, BYTE  cAdapterNum, HWND  hwndPost,     
  434.     WORD  wMsgPost, WORD  wParam, LPNCB FAR *lpRetNCB)    
  435. {
  436.     LPNCB  lpNCB;
  437.     WORD   wErrCode;
  438.     
  439.     if (!IsWindow(hwndPost))
  440.     {
  441.         return(NB_INVALID_WINDOW);
  442.     }
  443.     
  444.     lpNCB = CreateNCB(NETBIOS_DELETE_NAME, cAdapterNum);
  445.     
  446.     if (lpNCB == NULL)
  447.     {
  448.         return(NB_NO_FREE_NCB_ERR);
  449.     }
  450.     
  451.     if (lstrlen(szName) > MAX_NAME_SIZE)
  452.     {
  453.         szName[MAX_NAME_SIZE] = '\0';
  454.     }
  455.     _fmemcpy(lpNCB->cName, szName, lstrlen(szName));
  456.     
  457.     wErrCode = PostNetBIOS(lpNCB,hwndPost,wMsgPost, wParam);
  458.     
  459.     if (wErrCode != 0)
  460.     {
  461.         DestroyNCB(lpNCB);
  462.     }
  463.     else
  464.     {
  465.         *lpRetNCB = lpNCB;
  466.     }
  467.     return(wErrCode);
  468. }
  469.  
  470.  
  471. WORD FAR PASCAL _export Listen(WMODE  Mode, LPSTR  szName, LPSTR  szCallName,   
  472.     BYTE   cAdapterNum, BYTE   cRTO, BYTE   cSTO, HWND   hwndPost, LPBYTE cLSN,         
  473.     LPSTR  szRemoteName) 
  474. {
  475.     LPNCB  lpNCB;
  476.     WORD   wErrCode;
  477.     
  478.     lpNCB = CreateNCB(NETBIOS_LISTEN, cAdapterNum);
  479.     if (lpNCB == NULL)
  480.     {
  481.         return(NB_NO_FREE_NCB_ERR);
  482.     }
  483.     
  484.     if (lstrlen(szName) > MAX_NAME_SIZE)
  485.     {
  486.         szName[MAX_NAME_SIZE] = '\0';
  487.     }
  488.     
  489.     if (lstrlen(szCallName) > MAX_NAME_SIZE)
  490.     {
  491.         szCallName[MAX_NAME_SIZE] = '\0';
  492.     }
  493.     
  494.     lpNCB->cRTO = cRTO;
  495.     lpNCB->cSTO = cSTO;
  496.     _fmemcpy(lpNCB->cName, szName, lstrlen(szName));
  497.     _fmemcpy(lpNCB->cCallName, szCallName, lstrlen(szCallName));
  498.     
  499.     wErrCode = SubmitNCB(Mode, lpNCB, hwndPost);
  500.     
  501.     if (wErrCode == 0)
  502.     {
  503.         *cLSN = lpNCB->cLSN;
  504.         _fmemcpy(szRemoteName, lpNCB->cCallName, MAX_NAME_SIZE);
  505.         szRemoteName[MAX_NAME_SIZE] = '\0';
  506.     }
  507.     
  508.     DestroyNCB(lpNCB);
  509.     return(wErrCode);
  510. }
  511.  
  512.  
  513.  
  514. WORD FAR PASCAL _export PostListen(LPSTR szName, LPSTR szCallName, BYTE  cAdapterNum,  
  515.     BYTE  cRTO, BYTE  cSTO, HWND  hwndPost, WORD  wMsgPost, WORD  wParam, LPNCB FAR *lpRetNCB)    
  516. {
  517.     LPNCB  lpNCB;
  518.     WORD   wErrCode;
  519.     
  520.     if (!IsWindow(hwndPost))
  521.     {
  522.         return(NB_INVALID_WINDOW);
  523.     }
  524.     
  525.     lpNCB = CreateNCB(NETBIOS_LISTEN, cAdapterNum);
  526.     if (lpNCB == NULL)
  527.     {
  528.         return(NB_NO_FREE_NCB_ERR);
  529.     }
  530.     
  531.     if (lstrlen(szName) > MAX_NAME_SIZE)
  532.     {
  533.         szName[MAX_NAME_SIZE] = '\0';
  534.     }
  535.     
  536.     if (lstrlen(szCallName) > MAX_NAME_SIZE)
  537.     {
  538.         szCallName[MAX_NAME_SIZE] = '\0';
  539.     }
  540.     
  541.     lpNCB->cRTO = cRTO;
  542.     lpNCB->cSTO = cSTO;
  543.     _fmemcpy(lpNCB->cName, szName, lstrlen(szName));
  544.     _fmemcpy(lpNCB->cCallName, szCallName, lstrlen(szCallName));
  545.     
  546.     wErrCode = PostNetBIOS(lpNCB,hwndPost,wMsgPost,wParam);
  547.     
  548.     if (wErrCode != 0)
  549.     {
  550.         DestroyNCB(lpNCB);
  551.     }
  552.     else
  553.     {
  554.         *lpRetNCB = lpNCB;
  555.     }
  556.     return(wErrCode);
  557. }
  558.  
  559.  
  560. WORD FAR PASCAL _export Call(WMODE  Mode, LPSTR  szName, LPSTR  szCallName,   
  561.     BYTE   cAdapterNum, BYTE   cRTO, BYTE   cSTO, HWND   hwndPost, LPBYTE cLSN)         
  562. {
  563.     LPNCB  lpNCB;
  564.     WORD   wErrCode;
  565.     
  566.     lpNCB = CreateNCB(NETBIOS_CALL, cAdapterNum);
  567.  
  568.     if (lpNCB == NULL)
  569.     {
  570.         return(NB_NO_FREE_NCB_ERR);
  571.     }
  572.     
  573.     if (lstrlen(szName) > MAX_NAME_SIZE)
  574.     {
  575.         szName[MAX_NAME_SIZE] = '\0';
  576.     }
  577.     
  578.     if (lstrlen(szCallName) > MAX_NAME_SIZE)
  579.     {
  580.         szCallName[MAX_NAME_SIZE] = '\0';
  581.     }
  582.     
  583.     lpNCB->cRTO = cRTO;
  584.     lpNCB->cSTO = cSTO;
  585.     _fmemcpy(lpNCB->cName, szName, lstrlen(szName));
  586.     _fmemcpy(lpNCB->cCallName, szCallName, lstrlen(szCallName));
  587.     
  588.     wErrCode = SubmitNCB(Mode, lpNCB, hwndPost);
  589.     
  590.     if (wErrCode == 0)
  591.     {
  592.         *cLSN = lpNCB->cLSN;
  593.     }
  594.     
  595.     DestroyNCB(lpNCB);
  596.     return(wErrCode);
  597. }
  598.  
  599.  
  600. WORD FAR PASCAL _export PostCall(LPSTR szName, LPSTR szCallName, BYTE  cAdapterNum,  
  601.     BYTE  cRTO, BYTE  cSTO, HWND  hwndPost, WORD  wMsgPost, WORD  wParam, LPNCB FAR *lpRetNCB)    
  602. {
  603.     LPNCB  lpNCB;
  604.     WORD   wErrCode;
  605.     
  606.     if (!IsWindow(hwndPost))
  607.     {
  608.         return(NB_INVALID_WINDOW);
  609.     }
  610.     
  611.     lpNCB = CreateNCB(NETBIOS_CALL, cAdapterNum);
  612.     
  613.     if (lpNCB == NULL)
  614.     {
  615.         return(NB_NO_FREE_NCB_ERR);
  616.     }
  617.     
  618.     if (lstrlen(szName) > MAX_NAME_SIZE)
  619.     {
  620.         szName[MAX_NAME_SIZE] = '\0';
  621.     }
  622.     
  623.     if (lstrlen(szCallName) > MAX_NAME_SIZE)
  624.     {
  625.         szCallName[MAX_NAME_SIZE] = '\0';
  626.     }
  627.     
  628.     lpNCB->cRTO = cRTO;
  629.     lpNCB->cSTO = cSTO;
  630.     _fmemcpy(lpNCB->cName, szName, lstrlen(szName));
  631.     _fmemcpy(lpNCB->cCallName, szCallName, lstrlen(szCallName));
  632.     
  633.     wErrCode = PostNetBIOS(lpNCB,hwndPost,wMsgPost,    wParam);
  634.     
  635.     if (wErrCode != 0)
  636.     {
  637.         DestroyNCB(lpNCB);
  638.     }
  639.     else
  640.     {
  641.         *lpRetNCB = lpNCB;
  642.     }
  643.     return(wErrCode);
  644. }
  645.  
  646.  
  647. WORD FAR PASCAL _export HangUp(WMODE  Mode, BYTE  cAdapterNum, BYTE  cLSN, HWND  hwndPost)     
  648. {
  649.     LPNCB  lpNCB;
  650.     WORD   wErrCode;
  651.     
  652.     lpNCB = CreateNCB(NETBIOS_HANGUP, cAdapterNum);
  653.     
  654.     if (lpNCB == NULL)
  655.     {
  656.         return(NB_NO_FREE_NCB_ERR);
  657.     }
  658.     
  659.     lpNCB->cLSN = cLSN;
  660.     
  661.     wErrCode = SubmitNCB(Mode,lpNCB, hwndPost);
  662.     
  663.     DestroyNCB(lpNCB);
  664.     return(wErrCode);
  665. }
  666.  
  667.  
  668. WORD FAR PASCAL _export PostHangup(BYTE  cAdapterNum, BYTE  cLSN, HWND  hwndPost, 
  669.     WORD  wMsgPost, WORD  wParam, LPNCB FAR *lpRetNCB) 
  670. {
  671.     LPNCB  lpNCB;
  672.     WORD   wErrCode;
  673.     
  674.     if (!IsWindow(hwndPost))
  675.     {
  676.         return(NB_INVALID_WINDOW);
  677.     }
  678.     
  679.     lpNCB = CreateNCB(NETBIOS_HANGUP, cAdapterNum);
  680.     
  681.     if (lpNCB == NULL)
  682.     {
  683.         return(NB_NO_FREE_NCB_ERR);
  684.     }
  685.     
  686.     lpNCB->cLSN = cLSN;
  687.     
  688.     wErrCode = PostNetBIOS(lpNCB,hwndPost,wMsgPost,wParam);
  689.     
  690.     if (wErrCode != 0)
  691.     {
  692.         DestroyNCB(lpNCB);
  693.     }
  694.     else
  695.     {
  696.         *lpRetNCB = lpNCB;
  697.     }
  698.     return(wErrCode);
  699. }
  700.  
  701. WORD FAR PASCAL _export Send(WMODE  Mode, BYTE  cAdapterNum, BYTE  cLSN, LPSTR szBuffer,     
  702.     WORD  wBufLen, HWND  hwndPost)     
  703. {
  704.     LPNCB  lpNCB;
  705.     WORD   wErrCode;
  706.     
  707.     lpNCB = CreateNCB(NETBIOS_SEND, cAdapterNum);
  708.     
  709.     if (lpNCB == NULL)
  710.     {
  711.         return(NB_NO_FREE_NCB_ERR);
  712.     }
  713.     
  714.     lpNCB->cLSN = cLSN;
  715.     lpNCB->lpBuffer = szBuffer;
  716.     lpNCB->wLength = wBufLen;
  717.     
  718.     wErrCode = SubmitNCB(Mode, lpNCB, hwndPost);
  719.     
  720.     DestroyNCB(lpNCB);
  721.     return(wErrCode);
  722. }
  723.  
  724.  
  725. WORD FAR PASCAL _export PostSend(BYTE  cAdapterNum, BYTE  cLSN, LPSTR szBuffer,     
  726.     WORD  wBufLen, HWND  hwndPost, WORD  wMsgPost, WORD  wParam, LPNCB FAR *lpRetNCB)    
  727. {
  728.     LPNCB  lpNCB;
  729.     WORD   wErrCode;
  730.     
  731.     if (!IsWindow(hwndPost))
  732.     {
  733.         return(NB_INVALID_WINDOW);
  734.     }
  735.     
  736.     lpNCB = CreateNCB(NETBIOS_SEND, cAdapterNum);
  737.     
  738.     if (lpNCB == NULL)
  739.     {
  740.         return(NB_NO_FREE_NCB_ERR);
  741.     }
  742.     
  743.     lpNCB->cLSN = cLSN;
  744.     lpNCB->lpBuffer = szBuffer;
  745.     lpNCB->wLength = wBufLen;
  746.     
  747.     wErrCode = PostNetBIOS(lpNCB,hwndPost,wMsgPost,    wParam);
  748.     
  749.     if (wErrCode != 0)
  750.     {
  751.         DestroyNCB(lpNCB);
  752.     }
  753.     else
  754.     {
  755.         *lpRetNCB = lpNCB;
  756.     }
  757.     return(wErrCode);
  758. }
  759.  
  760.  
  761. WORD FAR PASCAL _export ChainSend(WMODE  Mode, BYTE  cAdapterNum, BYTE  cLSN, LPSTR szBuffer,     
  762.     WORD  wBufLen, LPSTR szBuffer2, WORD  wBufLen2, HWND  hwndPost)     
  763. {
  764.     LPNCB  lpNCB;
  765.     WORD   wErrCode;
  766.     
  767.     lpNCB = CreateNCB(NETBIOS_CHAIN_SEND, cAdapterNum);
  768.  
  769.     if (lpNCB == NULL)
  770.     {
  771.         return(NB_NO_FREE_NCB_ERR);
  772.     }
  773.     
  774.     lpNCB->cLSN = cLSN;
  775.     lpNCB->lpBuffer = szBuffer;
  776.     lpNCB->wLength = wBufLen;
  777.     _fmemcpy((LPSTR) &lpNCB->cCallName[2], (LPSTR) szBuffer2, sizeof(LPSTR));
  778.     _fmemcpy((LPSTR) &lpNCB->cCallName[0], (LPSTR) &wBufLen2, sizeof(WORD));
  779.     
  780.     wErrCode = SubmitNCB(Mode, lpNCB, hwndPost);
  781.     
  782.     DestroyNCB(lpNCB);
  783.     return(wErrCode);
  784. }
  785.  
  786.  
  787. WORD FAR PASCAL _export PostChainSend(BYTE  cAdapterNum, BYTE  cLSN, LPSTR szBuffer, 
  788.     WORD  wBufLen, LPSTR szBuffer2, WORD  wBufLen2, HWND  hwndPost, WORD  wMsgPost,     
  789.     WORD  wParam, LPNCB FAR *lpRetNCB)    
  790. {
  791.     LPNCB  lpNCB;
  792.     WORD   wErrCode;
  793.     
  794.     if (!IsWindow(hwndPost))
  795.     {
  796.         return(NB_INVALID_WINDOW);
  797.     }
  798.     
  799.     lpNCB = CreateNCB(NETBIOS_CHAIN_SEND, cAdapterNum);
  800.     
  801.     if (lpNCB == NULL)
  802.     {
  803.         return(NB_NO_FREE_NCB_ERR);
  804.     }
  805.     
  806.     lpNCB->cLSN = cLSN;
  807.     lpNCB->lpBuffer = szBuffer;
  808.     lpNCB->wLength = wBufLen;
  809.     _fmemcpy((LPSTR) &lpNCB->cCallName[2], (LPSTR) szBuffer2, sizeof(LPSTR));
  810.     _fmemcpy((LPSTR) &lpNCB->cCallName[0], (LPSTR) &wBufLen2, sizeof(WORD));
  811.     
  812.     wErrCode = PostNetBIOS(lpNCB,hwndPost,wMsgPost,wParam);
  813.     
  814.     if (wErrCode != 0)
  815.     {
  816.         DestroyNCB(lpNCB);
  817.     }
  818.     else
  819.     {
  820.         *lpRetNCB = lpNCB;
  821.     }
  822.     return(wErrCode);
  823. }
  824.  
  825.  
  826. WORD FAR PASCAL _export Receive(WMODE  Mode, BYTE  cAdapterNum, BYTE  cLSN, LPSTR szBuffer,     
  827.     LPWORD wBufLen, HWND  hwndPost)     
  828. {
  829.     LPNCB  lpNCB;
  830.     WORD   wErrCode;
  831.     
  832.     lpNCB = CreateNCB(NETBIOS_RECEIVE, cAdapterNum);
  833.     
  834.     if (lpNCB == NULL)
  835.     {
  836.         return(NB_NO_FREE_NCB_ERR);
  837.     }
  838.     
  839.     lpNCB->cLSN = cLSN;
  840.     lpNCB->lpBuffer = szBuffer;
  841.     lpNCB->wLength = *wBufLen;
  842.     
  843.     wErrCode = SubmitNCB(Mode, lpNCB, hwndPost);
  844.     
  845.     if (wErrCode == 0)
  846.     {
  847.         *wBufLen = lpNCB->wLength;
  848.     }
  849.     
  850.     DestroyNCB(lpNCB);
  851.     return(wErrCode);
  852. }
  853.  
  854.  
  855. WORD FAR PASCAL _export PostReceive(BYTE  cAdapterNum, BYTE  cLSN, LPSTR szBuffer,     
  856.     WORD  wBufLen, HWND  hwndPost, WORD  wMsgPost, WORD  wParam, LPNCB FAR *lpRetNCB) 
  857.  
  858. {
  859.     LPNCB  lpNCB;
  860.     WORD   wErrCode;
  861.     
  862.     if (!IsWindow(hwndPost))
  863.     {
  864.         return(NB_INVALID_WINDOW);
  865.     }
  866.     
  867.     lpNCB = CreateNCB(NETBIOS_RECEIVE, cAdapterNum);
  868.     
  869.     if (lpNCB == NULL)
  870.     {
  871.         return(NB_NO_FREE_NCB_ERR);
  872.     }
  873.     
  874.     lpNCB->cLSN = cLSN;
  875.     lpNCB->lpBuffer = szBuffer;
  876.     lpNCB->wLength = wBufLen;
  877.     
  878.     wErrCode = PostNetBIOS(lpNCB,hwndPost,wMsgPost,wParam);
  879.     
  880.     if (wErrCode != 0)
  881.     {
  882.         DestroyNCB(lpNCB);
  883.     }
  884.     else
  885.     {
  886.         *lpRetNCB = lpNCB;
  887.     }
  888.     return(wErrCode);
  889. }
  890.  
  891.  
  892. WORD FAR PASCAL _export SendBroadcast(WMODE  Mode, BYTE  cAdapterNum, BYTE  cNum,         
  893.     LPSTR szBuffer, WORD  wBufLen, HWND  hwndPost)     
  894. {
  895.     LPNCB  lpNCB;
  896.     WORD   wErrCode;
  897.     
  898.     lpNCB = CreateNCB(NETBIOS_SEND_BROADCAST, cAdapterNum);
  899.  
  900.     if (lpNCB == NULL)
  901.     {
  902.         return(NB_NO_FREE_NCB_ERR);
  903.     }
  904.     
  905.     lpNCB->cNum = cNum;
  906.     lpNCB->lpBuffer = szBuffer;
  907.     lpNCB->wLength = wBufLen;
  908.     
  909.     wErrCode = SubmitNCB(Mode, lpNCB, hwndPost);
  910.     
  911.     DestroyNCB(lpNCB);
  912.     return(wErrCode);
  913. }
  914.  
  915.  
  916. WORD FAR PASCAL _export PostSendBroadcast(BYTE  cAdapterNum, BYTE  cNum, LPSTR szBuffer,     
  917.     WORD  wBufLen, HWND  hwndPost, WORD  wMsgPost, WORD  wParam, LPNCB FAR *lpRetNCB) 
  918. {
  919.     LPNCB  lpNCB;
  920.     WORD   wErrCode;
  921.     
  922.     if (!IsWindow(hwndPost))
  923.     {
  924.         return(NB_INVALID_WINDOW);
  925.     }
  926.     
  927.     lpNCB = CreateNCB(NETBIOS_SEND_BROADCAST, cAdapterNum);
  928.     
  929.     if (lpNCB == NULL)
  930.     {
  931.         return(NB_NO_FREE_NCB_ERR);
  932.     }
  933.     lpNCB->cNum = cNum;
  934.     lpNCB->lpBuffer = szBuffer;
  935.     lpNCB->wLength = wBufLen;
  936.     
  937.     wErrCode = PostNetBIOS(lpNCB,hwndPost,wMsgPost,wParam);
  938.     
  939.     if (wErrCode != 0)
  940.     {
  941.         DestroyNCB(lpNCB);
  942.     }
  943.     else
  944.     {
  945.         *lpRetNCB = lpNCB;
  946.     }
  947.     return(wErrCode);
  948. }
  949.  
  950.  
  951. WORD FAR PASCAL _export ReceiveBroadcast(WMODE  Mode, BYTE  cAdapterNum, BYTE  cNum,         
  952.     LPSTR szBuffer, LPWORD wBufLen, HWND   hwndPost)    
  953. {
  954.     LPNCB  lpNCB;
  955.     WORD   wErrCode;
  956.     
  957.     lpNCB = CreateNCB(NETBIOS_RECEIVE_BROADCAST, cAdapterNum);
  958.  
  959.     if (lpNCB == NULL)
  960.     {
  961.         return(NB_NO_FREE_NCB_ERR);
  962.     }
  963.     
  964.     lpNCB->cNum = cNum;
  965.     lpNCB->lpBuffer = szBuffer;
  966.     lpNCB->wLength = *wBufLen;
  967.     
  968.     wErrCode = SubmitNCB(Mode, lpNCB, hwndPost);
  969.     
  970.     if (wErrCode == 0)
  971.     {
  972.         *wBufLen = lpNCB->wLength;
  973.     }
  974.     
  975.     DestroyNCB(lpNCB);
  976.     return(wErrCode);
  977. }
  978.  
  979.  
  980. WORD FAR PASCAL _export PostReceiveBroadcast(BYTE  cAdapterNum, BYTE  cNum, LPSTR szBuffer,     
  981.     WORD  wBufLen, HWND  hwndPost, WORD  wMsgPost, WORD  wParam, LPNCB FAR *lpRetNCB) 
  982. {
  983.     LPNCB  lpNCB;
  984.     WORD   wErrCode;
  985.     
  986.     if (!IsWindow(hwndPost))
  987.     {
  988.         return(NB_INVALID_WINDOW);
  989.     }
  990.     
  991.     lpNCB = CreateNCB(NETBIOS_RECEIVE_BROADCAST, cAdapterNum);
  992.     
  993.     if (lpNCB == NULL)
  994.     {
  995.         return(NB_NO_FREE_NCB_ERR);
  996.     }
  997.     
  998.     lpNCB->cNum = cNum;
  999.     lpNCB->lpBuffer = szBuffer;
  1000.     lpNCB->wLength = wBufLen;
  1001.     
  1002.     wErrCode = PostNetBIOS(lpNCB,hwndPost,wMsgPost,wParam);
  1003.     
  1004.     if (wErrCode != 0)
  1005.     {
  1006.         DestroyNCB(lpNCB);
  1007.     }
  1008.     else
  1009.     {
  1010.         *lpRetNCB = lpNCB;
  1011.     }
  1012.     return(wErrCode);
  1013. }
  1014.  
  1015.  
  1016. WORD FAR PASCAL _export SendDatagram(WMODE  Mode, BYTE  cAdapterNum, BYTE  cNum,         
  1017.     LPSTR szCallName, LPSTR szBuffer, WORD  wBufLen, HWND  hwndPost)     
  1018. {
  1019.     LPNCB  lpNCB;
  1020.     WORD   wErrCode;
  1021.     
  1022.     lpNCB = CreateNCB(NETBIOS_SEND_DATAGRAM, cAdapterNum);
  1023.     
  1024.     if (lpNCB == NULL)
  1025.     {
  1026.         return(NB_NO_FREE_NCB_ERR);
  1027.     }
  1028.     
  1029.     lpNCB->cNum = cNum;
  1030.     _fmemcpy(lpNCB->cCallName, szCallName, lstrlen(szCallName));
  1031.     lpNCB->lpBuffer = szBuffer;
  1032.     lpNCB->wLength = wBufLen;
  1033.     
  1034.     wErrCode = SubmitNCB(Mode, lpNCB, hwndPost);
  1035.     
  1036.     DestroyNCB(lpNCB);
  1037.     return(wErrCode);
  1038. }
  1039.  
  1040.  
  1041. WORD FAR PASCAL _export PostSendDatagram(BYTE  cAdapterNum, BYTE  cNum, LPSTR szCallName,   
  1042.     LPSTR szBuffer, WORD  wBufLen, HWND  hwndPost, WORD  wMsgPost, WORD  wParam, LPNCB FAR *lpRetNCB) 
  1043.  
  1044. {
  1045.     LPNCB  lpNCB;
  1046.     WORD   wErrCode;
  1047.     
  1048.     if (!IsWindow(hwndPost))
  1049.     {
  1050.         return(NB_INVALID_WINDOW);
  1051.     }
  1052.     
  1053.     lpNCB = CreateNCB(NETBIOS_SEND_DATAGRAM, cAdapterNum);
  1054.     
  1055.     if (lpNCB == NULL)
  1056.     {
  1057.         return(NB_NO_FREE_NCB_ERR);
  1058.     }
  1059.     
  1060.     lpNCB->cNum = cNum;
  1061.     _fmemcpy(lpNCB->cCallName, szCallName, lstrlen(szCallName));
  1062.     lpNCB->lpBuffer = szBuffer;
  1063.     lpNCB->wLength = wBufLen;
  1064.     
  1065.     wErrCode = PostNetBIOS(lpNCB,hwndPost,wMsgPost,wParam);
  1066.     
  1067.     if (wErrCode != 0)
  1068.     {
  1069.         DestroyNCB(lpNCB);
  1070.     }
  1071.     else
  1072.     {
  1073.         *lpRetNCB = lpNCB;
  1074.     }
  1075.     return(wErrCode);
  1076. }
  1077.  
  1078.  
  1079. WORD FAR PASCAL _export ReceiveDatagram(WMODE  Mode, BYTE  cAdapterNum, BYTE  cNum, LPSTR szBuffer,      
  1080.     LPWORD wBufLen, HWND   hwndPost, LPSTR szCallName)    
  1081. {
  1082.     LPNCB  lpNCB;
  1083.     WORD   wErrCode;
  1084.     
  1085.     lpNCB = CreateNCB(NETBIOS_RECEIVE_DATAGRAM, cAdapterNum);
  1086.  
  1087.     if (lpNCB == NULL)
  1088.     {
  1089.         return(NB_NO_FREE_NCB_ERR);
  1090.     }
  1091.     
  1092.     lpNCB->cNum = cNum;
  1093.     lpNCB->lpBuffer = szBuffer;
  1094.     lpNCB->wLength = *wBufLen;
  1095.     
  1096.     wErrCode = SubmitNCB(Mode, lpNCB, hwndPost);
  1097.     
  1098.     if (wErrCode == 0)
  1099.     {
  1100.         _fmemcpy(lpNCB->cCallName, szCallName, lstrlen(szCallName));
  1101.         *wBufLen = lpNCB->wLength;
  1102.     }
  1103.     
  1104.     DestroyNCB(lpNCB);
  1105.     return(wErrCode);
  1106. }
  1107.  
  1108.  
  1109. WORD FAR PASCAL _export PostReceiveDatagram(BYTE  cAdapterNum, BYTE  cNum, LPSTR szBuffer,     
  1110.     WORD  wBufLen, HWND  hwndPost, WORD  wMsgPost, WORD  wParam, LPNCB FAR *lpRetNCB) 
  1111. {
  1112.     LPNCB  lpNCB;
  1113.     WORD   wErrCode;
  1114.     
  1115.     if (!IsWindow(hwndPost))
  1116.     {
  1117.         return(NB_INVALID_WINDOW);
  1118.     }
  1119.     
  1120.     lpNCB = CreateNCB(NETBIOS_RECEIVE_DATAGRAM, cAdapterNum);
  1121.     
  1122.     if (lpNCB == NULL)
  1123.     {
  1124.         return(NB_NO_FREE_NCB_ERR);
  1125.     }
  1126.     
  1127.     lpNCB->cNum = cNum;
  1128.     lpNCB->lpBuffer = szBuffer;
  1129.     lpNCB->wLength = wBufLen;
  1130.     
  1131.     wErrCode = PostNetBIOS(lpNCB,hwndPost,wMsgPost,wParam);
  1132.     
  1133.     if (wErrCode != 0)
  1134.     {
  1135.         DestroyNCB(lpNCB);
  1136.     }
  1137.     else
  1138.     {
  1139.         *lpRetNCB = lpNCB;
  1140.     }
  1141.     return(wErrCode);
  1142. }
  1143.  
  1144. WORD FAR PASCAL _export Cancel(BYTE  cAdapterNum, LPNCB lpPreviousNCB) 
  1145. {
  1146.     LPNCB  lpNCB;
  1147.     WORD   wErrCode;
  1148.     
  1149.     lpNCB = CreateNCB(NETBIOS_CANCEL, cAdapterNum);
  1150.     
  1151.     if (lpNCB == NULL)
  1152.     {
  1153.         return(NB_NO_FREE_NCB_ERR);
  1154.     }
  1155.     
  1156.     lpNCB->lpBuffer = (LPSTR) lpPreviousNCB;
  1157.     wErrCode = SendNetBIOS(lpNCB);
  1158.     
  1159.     DestroyNCB(lpNCB);
  1160.     return(wErrCode);
  1161. }
  1162.  
  1163. WORD FAR PASCAL _export Reset(BYTE  cAdapterNum, BYTE  cMaxLSN, BYTE  cMaxCmd)      
  1164. {
  1165.     LPNCB  lpNCB;
  1166.     WORD   wErrCode;
  1167.     
  1168.     lpNCB = CreateNCB(NETBIOS_RESET, cAdapterNum);
  1169.     
  1170.     if (lpNCB == NULL)
  1171.     {
  1172.         return(NB_NO_FREE_NCB_ERR);
  1173.     }
  1174.     
  1175.     lpNCB->cLSN = cMaxLSN;
  1176.     lpNCB->cNum = cMaxCmd;
  1177.     
  1178.     wErrCode = SendNetBIOS(lpNCB);
  1179.     
  1180.     DestroyNCB(lpNCB);
  1181.     return(wErrCode);
  1182. }
  1183.  
  1184. WORD FAR PASCAL _export SessionStatus(WMODE  Mode, BYTE  cAdapterNum, LPSTR szName,       
  1185.     LPSESSIONSTAT lpSessionStat, LPWORD wBufLen, HWND   hwndPost)    
  1186. {
  1187.     LPNCB  lpNCB;
  1188.     WORD   wErrCode;
  1189.     
  1190.     lpNCB = CreateNCB(NETBIOS_SESSION_STATUS, cAdapterNum);
  1191.     
  1192.     if (lpNCB == NULL)
  1193.     {
  1194.         return(NB_NO_FREE_NCB_ERR);
  1195.     }
  1196.     
  1197.     _fmemcpy(lpNCB->cName, szName, lstrlen(szName));
  1198.     lpNCB->lpBuffer = (LPSTR) lpSessionStat;
  1199.     lpNCB->wLength = *wBufLen;
  1200.     
  1201.     wErrCode = SubmitNCB(Mode, lpNCB, hwndPost);
  1202.     
  1203.     if (wErrCode == 0)
  1204.     {
  1205.         *wBufLen = lpNCB->wLength;
  1206.     }
  1207.     
  1208.     DestroyNCB(lpNCB);
  1209.     return(wErrCode);
  1210. }
  1211.  
  1212. WORD FAR PASCAL _export PostSessionStatus(BYTE  cAdapterNum, LPSTR szName, 
  1213.     LPSESSIONSTAT lpSessionStat, WORD  wBufLen, HWND  hwndPost, WORD  wMsgPost, WORD  wParam,       
  1214.     LPNCB FAR *lpRetNCB) 
  1215. {
  1216.     LPNCB  lpNCB;
  1217.     WORD   wErrCode;
  1218.     
  1219.     if (!IsWindow(hwndPost))
  1220.     {
  1221.         return(NB_INVALID_WINDOW);
  1222.     }
  1223.     
  1224.     lpNCB = CreateNCB(NETBIOS_SESSION_STATUS, cAdapterNum);
  1225.     
  1226.     if (lpNCB == NULL)
  1227.     {
  1228.         return(NB_NO_FREE_NCB_ERR);
  1229.     }
  1230.     
  1231.     _fmemcpy(lpNCB->cName, szName, lstrlen(szName));
  1232.     lpNCB->lpBuffer = (LPSTR) lpSessionStat;
  1233.     lpNCB->wLength = wBufLen;
  1234.     
  1235.     wErrCode = PostNetBIOS(lpNCB,hwndPost,wMsgPost,wParam);
  1236.     
  1237.     if (wErrCode != 0)
  1238.     {
  1239.         DestroyNCB(lpNCB);
  1240.     }
  1241.     else
  1242.     {
  1243.         *lpRetNCB = lpNCB;
  1244.     }
  1245.     return(wErrCode);
  1246. }
  1247.  
  1248. WORD FAR PASCAL _export AdapterStatus(WMODE  Mode, BYTE  cAdapterNum, LPSTR szCallName,   
  1249.     LPLANASTAT lpLanaStat, LPWORD   wBufLen, HWND     hwndPost)  
  1250. {
  1251.     LPNCB  lpNCB;
  1252.     WORD   wErrCode;
  1253.     
  1254.     lpNCB = CreateNCB(NETBIOS_ADAPTER_STATUS, cAdapterNum);
  1255.  
  1256.     if (lpNCB == NULL)
  1257.     {
  1258.         return(NB_NO_FREE_NCB_ERR);
  1259.     }
  1260.     
  1261.     _fmemcpy(lpNCB->cCallName, szCallName, lstrlen(szCallName));
  1262.     lpNCB->lpBuffer = (LPSTR) lpLanaStat;
  1263.     lpNCB->wLength = *wBufLen;
  1264.     
  1265.     wErrCode = SubmitNCB(Mode, lpNCB, hwndPost);
  1266.     
  1267.     if (wErrCode == 0)
  1268.     {
  1269.         *wBufLen = lpNCB->wLength;
  1270.     }
  1271.     
  1272.     DestroyNCB(lpNCB);
  1273.     return(wErrCode);
  1274. }
  1275.  
  1276.  
  1277. WORD FAR PASCAL _export PostAdapterStatus(BYTE  cAdapterNum, LPSTR szCallName, 
  1278.     LPLANASTAT lpLanaStat, WORD  wBufLen, HWND  hwndPost, WORD  wMsgPost,     
  1279.     WORD  wParam, LPNCB FAR *lpRetNCB) 
  1280. {
  1281.     LPNCB  lpNCB;
  1282.     WORD   wErrCode;
  1283.     
  1284.     if (!IsWindow(hwndPost))
  1285.     {
  1286.         return(NB_INVALID_WINDOW);
  1287.     }
  1288.     
  1289.     lpNCB = CreateNCB(NETBIOS_ADAPTER_STATUS, cAdapterNum);
  1290.     
  1291.     if (lpNCB == NULL)
  1292.     {
  1293.         return(NB_NO_FREE_NCB_ERR);
  1294.     }
  1295.     
  1296.     _fmemcpy(lpNCB->cCallName, szCallName, lstrlen(szCallName));
  1297.     lpNCB->lpBuffer = (LPSTR) lpLanaStat;
  1298.     lpNCB->wLength = wBufLen;
  1299.     
  1300.     wErrCode = PostNetBIOS(lpNCB,hwndPost,wMsgPost,wParam);
  1301.     
  1302.     if (wErrCode != 0)
  1303.     {
  1304.         DestroyNCB(lpNCB);
  1305.     }
  1306.     else
  1307.     {
  1308.         *lpRetNCB = lpNCB;
  1309.     }
  1310.     return(wErrCode);
  1311. }
  1312.  
  1313. WORD FAR PASCAL _export UnlinkRPL(BYTE cAdapterNum)  
  1314. {
  1315.     LPNCB  lpNCB;
  1316.     WORD   wErrCode;
  1317.     
  1318.     lpNCB = CreateNCB(NETBIOS_UNLINK, cAdapterNum);
  1319.     
  1320.     if (lpNCB == NULL)
  1321.     {
  1322.         return(NB_NO_FREE_NCB_ERR);
  1323.     }
  1324.     wErrCode = SendNetBIOS(lpNCB);
  1325.     
  1326.     DestroyNCB(lpNCB);
  1327.     return(wErrCode);
  1328. }
  1329.  
  1330. LPSTR FAR PASCAL _export WNB_Error()
  1331. {
  1332.     static char errtxt[80];
  1333.     int rc;
  1334.     
  1335.     rc = LoadString(hLibrary, 100 + net_errno, errtxt, sizeof(errtxt));
  1336.     
  1337.     if(rc == 0)
  1338.     {
  1339.         wsprintf(errtxt, "Kein/Unbekannter Fehler (0x%x)", net_errno);
  1340.     }
  1341.     return(errtxt);
  1342. }
  1343.